//
//  GoodsDetSecendCell.m
//  NormalFramework
//
//  Created by beisheng03 on 2018/3/17.
//  Copyright © 2018年 beisheng. All rights reserved.
//

#import "GoodsDetSecendCell.h"

@interface GoodsDetSecendCell ()
@property (weak, nonatomic) IBOutlet UILabel *topLabel;
@property (weak, nonatomic) IBOutlet UILabel *markLabel;


@end

@implementation GoodsDetSecendCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    self.topLabel.font = MYFONT(16);
    
    self.markLabel.textColor = themeColor;
    
    self.markLabel.font = BigTitleFont;
    
    self.markLabel.layer.cornerRadius = 3;
    self.markLabel.layer.masksToBounds = YES;
    
    self.markLabel.layer.borderColor = themeColor.CGColor;
    self.markLabel.layer.borderWidth = 0.6;
    
    
    // Initialization code
}

- (void)setGoodsName:(NSString *)goodsName{
    

    _goodsName = [NSString stringWithFormat:@"%@ ",goodsName];
    self.topLabel.attributedText = [self getAttributedString];
}


- (NSMutableAttributedString *)getAttributedString{
    
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
    paragraphStyle.firstLineHeadIndent = 56;
    
    paragraphStyle.lineSpacing = 5;
    paragraphStyle.paragraphSpacing = 2;
    
    NSDictionary *dic = @{
                          
                          NSForegroundColorAttributeName : [UIColor blackColor],
                          NSFontAttributeName : MYFONT(16),
                          
                          NSParagraphStyleAttributeName :paragraphStyle
                          
                          };
    
    
    //实现富文本
    NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:self.goodsName attributes:dic];
    

    //    //进行图文混排
        NSTextAttachment *textAttachment = [[NSTextAttachment alloc] initWithData:nil ofType:nil];
        textAttachment.image = [UIImage imageNamed:@"hongbao"];
        textAttachment.bounds = CGRectMake(0, -5, 128 * 0.12,175 * 0.12);
        NSAttributedString * textAttachmentString1 = [NSAttributedString attributedStringWithAttachment:textAttachment ];
        [string insertAttributedString:textAttachmentString1 atIndex:string.length];
    
        return string;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
